/*
 * NT35510.h
 *
 *  Created on: May 14, 2021
 *      Author: gary
 */

#ifndef INC_NT35510_H_
#define INC_NT35510_H_

#include "main.h"
#include "tim.h"
#include "gpio.h"
#include "fmc.h"

typedef struct __NT35510_FMC_AddressTypeDef
{
  __IO uint16_t reg;
  __IO uint16_t ram;
} NT35510_FMC_AddressTypeDef;

typedef struct __NT35510_AttributeTypeDef
{
  uint16_t      width;
  uint16_t      height;
  uint16_t      id;
  uint8_t       direction;
  uint16_t      wram_cmd;
  uint16_t      set_x_cmd;
  uint16_t      set_y_cmd;
} NT35510_AttributeTypeDef;

#define CMD_GRAM        0x2C00
#define CMD_SET_X       0x2A00
#define CMD_SET_Y       0x2B00

#define LCD_WIDTH       480
#define LCD_HEIGHT      800

#define NT35510_BASE    ((uint32_t)(0x60000000UL | 0x0007FFFEUL))
#define NT35510         ((NT35510_FMC_AddressTypeDef*) NT35510_BASE)

#define WHITE           0xFFFF
#define BLACK           0x0000
#define BLUE            0x001F
#define BRED            0XF81F
#define GRED            0XFFE0
#define GBLUE           0X07FF
#define RED             0xF800
#define MAGENTA         0xF81F
#define GREEN           0x07E0
#define CYAN            0x7FFF
#define YELLOW          0xFFE0
#define BROWN           0XBC40 //棕色
#define BRRED           0XFC07 //棕红色
#define GRAY            0X8430 //灰色

void NT35510_WriteCmd(__I uint16_t cmd);
void NT35510_WriteData(__I uint16_t data);
uint16_t NT35510_ReadData(void);
void NT35510_WriteReg(__I uint16_t reg, __I uint16_t data);
uint16_t NT35510_ReadReg(__I uint16_t reg);

int NT35510_ReadID(void);
void NT35510_DisplayOn(void);
void NT35510_DisplayOff(void);
void NT35510_SetCursor(uint16_t x, uint16_t y);
void NT35510_SetCursorEnd(uint16_t width, uint16_t height);
void NT35510_SetWindow(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
void NT35510_DrawPoint(uint16_t x, uint16_t y, uint16_t color);
void NT35510_SetWindow(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
void NT35510_Clear(uint16_t color);
void NT35510_Init(void);

#endif /* INC_NT35510_H_ */
